﻿@{
    ViewBag.Title = "Index";
}
@using EFramework.Web.Framework.Extends;
@model EFramework.Entities.Domain.ControlPanel.SYS_ConfigContentEntity
@section bread
{
    <li><a href="@Url.Action("sysconfig", "controlpanel")">控制面板</a></li>
    <li class="active">系统配置</li>
}
<div class="page-content">
    <div class="page-header">
        <h1>编辑系统配置
		@*<small>
            <i class="icon-double-angle-right"></i>
            overview &amp; stats
        </small>*@
        </h1>
    </div>
    <div class="row">
        <div class="col-xs-12">
            @using (Ajax.EFBeginForm("EditConfig", "Controlpanel"))
            {
                <input type="hidden" value="@Model.ID" name="ID" />
                <div class="form-group">
                    <label for="Keyname" class="col-sm-3 control-label no-padding-right">项目 </label>

                    <div class="col-sm-9">
                        <div class="clearfix">
                            <input type="text" id="Keyname" class="col-xs-12 col-sm-8" name="Keyname" value="@Model.Keyname" placeholder="项目键，字母和下划线">
                        </div>
                    </div>
                </div>
                
                <div class="form-group ">
                    <label for="Value" class="col-sm-3 control-label no-padding-right">值</label>

                    <div class="col-sm-9">
                        <div class="clearfix">
                            <textarea name="Value" id="Value" class="col-xs-12 col-sm-8" placeholder="请输入项目值">@Model.Value</textarea>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="Description" class="col-sm-3 control-label no-padding-right">描述</label>

                    <div class="col-sm-9">
                        <div class="clearfix">
                            <textarea name="Description" id="Description" class="col-xs-12 col-sm-8" placeholder="请输入项目描述信息">@Model.Description</textarea>
                        </div>
                    </div>
                </div>

                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button type="submit" class="btn btn-info">
                            <i class="icon-ok bigger-110"></i>
                            保存		
                        </button>
                        &nbsp; &nbsp; &nbsp;			
                    <button type="reset" class="btn">
                        <i class="icon-undo bigger-110"></i>
                        重置
                    </button>
                    </div>
                </div>

            }
        </div>
    </div>
</div>
@section scripts{
    <script>
        function OnSuccess(data) {
            if (data.status == 1) {
                alert("修改成功");
            }
            else {
                alert(data.message);
            }
        }

        $('#myform').validate({
            errorElement: 'div',
            errorClass: 'help-block',
            focusInvalid: false,

            rules: {
                Keyname: {
                    required: true
                },
                Value: {
                    required: true
                }
            },
            messages: {
                Keyname: {
                    required: "项目名称不能为空."
                },
                Value: {
                    required: "项值不能为空"
                }
            },

            highlight: function (e) {
                $(e).parents('.form-group').removeClass('has-info').addClass('has-error');
            },

            unhighlight: function (e) {
                $(e).closest('.form-group').removeClass('has-error').addClass('has-info');
                $(e).parents('.form-group').removeClass('has-error').addClass('has-info');
                //$(e).remove();
            },

            errorPlacement: function (error, element) {

                //if (element.is(':checkbox') || element.is(':radio')) {
                //    var controls = element.closest('div[class*="col-"]');
                //    if (controls.find(':checkbox,:radio').length > 1) controls.append(error);
                //    else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
                //}
                //else if (element.is('.select2')) {
                //    error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
                //}
                //else if (element.is('.chosen-select')) {
                //    error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
                //}
                //else
                //    error.insertAfter(element.parent());

                error.appendTo(element.parents('.col-sm-9'));
            }

        });
    </script>
}